﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace TestConsoleApp
{
    public class TestTAP
    {

        public static void Test()
        {
            Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} main thread {Thread.CurrentThread.ManagedThreadId} start");
            Calculate();
            Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} main thread {Thread.CurrentThread.ManagedThreadId} end");

        }


        public static async void Calculate()
        {
            Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} calculate method thread {Thread.CurrentThread.ManagedThreadId} start");
            await Task.Run(() =>
            {
                Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} calculate task thread {Thread.CurrentThread.ManagedThreadId} start");
                Thread.Sleep(3000);
                Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} calculate task thread {Thread.CurrentThread.ManagedThreadId} end");
            });

            Console.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")} calculate method thread {Thread.CurrentThread.ManagedThreadId} end");
        }
    }
}
